<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
  <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
  <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
</head>
<body style="padding:10px;">
  <div class="tplay-body-div">
    <div class="layui-tab">
      <ul class="layui-tab-title">
        <li><a href="{:url('admin/population/index')}" class="a_menu">拆迁人口管理</a></li>
        <li class="layui-this">新增户主</li>
        <li><a href="{:url('admin/population/daoru')}" class="a_menu">批量导入户主</a></li>
      </ul>
    </div>
    <div style="margin-top: 20px;">
    </div>
    <form class="layui-form" id="admin">

      <div class="layui-form-item">
        <label class="layui-form-label">拆迁编号</label>
        <div class="layui-input-inline">
          <input name="chainum" lay-verify="required" placeholder="请输入拆迁编号" autocomplete="off" class="layui-input" type="text" {notempty name="$cate.chainum"}value="{$cate.chainum}"{/notempty}>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">评估编号</label>
        <div class="layui-input-inline">
          <input name="pingnum" lay-verify="required" placeholder="请输入评估编号" autocomplete="off" class="layui-input" type="text" {notempty name="$cate.pingnum"}value="{$cate.pingnum}"{/notempty}>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">户主姓名</label>
        <div class="layui-input-inline">
          <input name="name" lay-verify="required" placeholder="请输入户主姓名" autocomplete="off" class="layui-input" type="text" {notempty name="$cate.name"}value="{$cate.name}"{/notempty}>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">家庭成员</label>
        <div class="layui-input-inline">
          <input name="family" lay-verify="required" placeholder="请输入家庭成员" autocomplete="off" class="layui-input" type="tel" {notempty name="$cate.family"}value="{$cate.family}"{/notempty}>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">与户主关系</label>
        <div class="layui-input-inline">
          <input name="relation" lay-verify="required" readonly value="户主" autocomplete="off" class="layui-input" type="text" {notempty name="$cate.relation"}value="{$cate.relation}"{/notempty}>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-inline">
          <select name="sex" lay-filter="aihao">
            <option>请选择性别</option>
            <option value="男">男</option>
            <option value="女">女</option>
          </select>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">年龄</label>
        <div class="layui-input-inline">
          <input name="age" lay-verify="required" placeholder="请输入年龄" autocomplete="off" class="layui-input" type="text" {notempty name="$cate.age"}value="{$cate.age}"{/notempty}>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">身份证号</label>
        <div class="layui-input-inline">
          <input name="idcar" lay-verify="required" placeholder="请输入身份证号" autocomplete="off" class="layui-input" type="text" {notempty name="$cate.idcar"}value="{$cate.idcar}"{/notempty}>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">是否基本村民</label>
        <div class="layui-input-inline">
          <select name="iscun" lay-filter="aihao">
            <option>请选择</option>
            <option value="是">是</option>
            <option value="否">否</option>
          </select>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">拆迁状态</label>
        <div class="layui-input-inline">
          <select name="status" lay-filter="aihao">
            <option>请选择</option>
            <option value="1">已完成</option>
            <option value="2">已签</option>
            <option value="3">已联系</option>
            <option value="4">未联系</option>
          </select>
        </div>
      </div>
      <div class="layui-form-item">
        <div class="layui-input-block">
          <button class="layui-btn" lay-submit lay-filter="admin">立即提交</button>
          <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
      </div>
    </form>
    <script src="__PUBLIC__/layui/layui.js"></script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>
    <script>
        var message;
        layui.config({
            base: '__JS__/',
            version: '1.0.1'
        }).use(['app', 'message'], function() {
            var app = layui.app,
                $ = layui.jquery,
                layer = layui.layer;
            //将message设置为全局以便子页面调用
            message = layui.message;
            //主入口
            app.set({
                type: 'iframe'
            }).init();
        });
    </script>
    <script>
      layui.use(['layer', 'form'], function() {
          var layer = layui.layer,
              $ = layui.jquery,
              form = layui.form;
          $(window).on('load', function() {
              form.on('submit(admin)', function(data) {
                  $.ajax({
                      url:"{:url('admin/population/add')}",
                      data:$('#admin').serialize(),
                      type:'post',
                      async: false,
                      success:function(res) {
                        if(res.code == 1) {
                            layer.alert('新增成功！',{icon:6},window.location.href = "{:url('admin/population/index')}");
                        }else {
                            layer.msg(res.msg);
                        }
                      }
                  })
                  return false;
              });
          });
      });
    </script>
  </div>
</body>
</html>